<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <!-- 满足有些用户在手机端访问的需要 -->

    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="0">

    <title>个人信息</title>
    <!-- 线上环境 -->
    <link rel="stylesheet" href="/static/css/dist/component-min.css">
    <link rel="stylesheet" href="/static/plugins/jbox/jbox-min.css">

    <!--vue-->
    <script src="/static/vue/vue.js"></script>
    <!--element ui-->
    <script src="/static/element/index.js"></script>
    <link rel="stylesheet" href="/static/element/index.css">
    <style>
        .el-table__empty-block {
            height: 0;
        }
    </style>

</head>
<body class="cp-bodybox">
<div id="app">
    <#include "/common/header-fg.html" />

    <div class="container">
        <div class="inner clearfix">
            <#include "/common/left-menu-fg.html" />

            <div class="content-right">
                <h1 class="content-right-title">个人信息</h1>
                <el-tabs value="user" type="border-card">
                    <el-tab-pane label="我的信息" name="user">
                        <div>
                            <el-form :model="userData" :rules="rules" label-width="100px">
                                <el-form-item label="姓名">
                                    <el-input v-model="userData.realName" style="width: 200px;"></el-input>
                                </el-form-item>
                                <el-form-item label="手机号码" prop="tel">
                                    <el-input v-model="userData.tel" style="width: 200px;"></el-input>
                                </el-form-item>
                                <el-form-item label="性别">
                                    <el-radio-group v-model="userData.sex" style="margin-top: 10px">
                                        <el-radio :label="1">男</el-radio>
                                        <el-radio :label="2">女</el-radio>
                                    </el-radio-group>
                                </el-form-item>
                                <el-form-item label="qq">
                                    <el-input v-model="userData.qq" style="width: 200px;"></el-input>
                                </el-form-item>
                                <el-form-item label="电子邮箱">
                                    <el-input v-model="userData.email" style="width: 200px;"></el-input>
                                </el-form-item>
                                <el-form-item label="头像" prop="avatar">
                                    <el-row>
                                        <img height="100" v-if="userData.avatar !== ''" :src="qiniuUrl + userData.avatar">
                                        <el-upload
                                                :before-upload="beforeUpload"
                                                style="display: inline-block"
                                                :show-file-list="false"
                                                action="/file/upload"
                                                :on-success="uploadSuccess">
                                            <el-button size="small" type="primary">点击上传</el-button>
                                            <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
                                        </el-upload>
                                    </el-row>
                                </el-form-item>
                                <el-form-item>
                                    <el-button :disabled="userDataBtnEnable" type="primary" @click="saveUser">保存</el-button>
                                    <el-button :disabled="userDataBtnEnable" @click="cancelEdit">取消</el-button>
                                </el-form-item>
                            </el-form>
                        </div>
                    </el-tab-pane>
                    <el-tab-pane label="我的商家" name="org" v-if="user.info.orgId !== 1">
                        <el-tabs value="first" type="border-card">
                            <el-tab-pane label="基本信息" name="first">
                                <el-form :inline="true" ref="orgBaseInfo" :model="org.baseInfo" label-width="80px">
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="上级商家">
                                                <el-input v-model="org.baseInfo.pid" :disabled="readonly"></el-input>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="名称">
                                                <el-input v-model="org.baseInfo.name" :disabled="readonly"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="状态">
                                                <el-select v-model="org.baseInfo.status" placeholder="请选择状态" :disabled="readonly">
                                                    <el-option label="审核不通过" value="-1"></el-option>
                                                    <el-option label="待审核" value="0"></el-option>
                                                    <el-option label="审核通过" value="1"></el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="地址">
                                                <el-input v-model="org.baseInfo.city" :disabled="readonly"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="24">
                                            <el-form-item label="详细地址">
                                                <el-input type="textarea" v-model="org.baseInfo.address" style="width: 300px" :disabled="readonly"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="邮政编码">
                                                <el-input v-model="org.baseInfo.zipCode" :disabled="readonly"></el-input>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="传真号码">
                                                <el-input v-model="org.baseInfo.fax" :disabled="readonly"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="联系人">
                                                <el-input v-model="org.baseInfo.linkName" :disabled="readonly"></el-input>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="联系电话">
                                                <el-input v-model="org.baseInfo.linkTel" :disabled="readonly"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="电子邮箱">
                                                <el-input v-model="org.baseInfo.email" :disabled="readonly"></el-input>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                </el-form>
                            </el-tab-pane>
                            <el-tab-pane label="营业信息" name="second">
                                <el-card class="box-card">
                                    <el-form :inline="true" ref="orgExtend" :model="org.extend" label-width="80px">
                                        <el-row>
                                            <!--<el-col :span="12">-->
                                                <!--<el-form-item label="企业性质">-->
                                                    <!--<el-select v-model="org.extend.character" :disabled="readonly" placeholder="请选择性质">-->
                                                        <!--<el-option-->
                                                                <!--v-for="item in natureList"-->
                                                                <!--:label="item.label"-->
                                                                <!--:value="item.value">-->
                                                        <!--</el-option>-->
                                                    <!--</el-select>-->
                                                <!--</el-form-item>-->
                                            <!--</el-col>-->
                                            <el-col :span="12">
                                                <el-form-item label="创立时间">
                                                    <el-date-picker
                                                            v-model="org.extend.establishTime" :disabled="readonly"
                                                            type="date"
                                                            placeholder="选择日期">
                                                    </el-date-picker>
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item label="执照号码">
                                                    <el-input v-model="org.extend.licenseCode" :disabled="readonly"></el-input>
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item label="员工数">
                                                    <el-input v-model="org.extend.staffNumber" :disabled="readonly"></el-input>
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col :span="24">
                                                <el-form-item label="经营范围">
                                                    <el-input type="textarea" v-model="org.extend.businessScope" style="width: 300px" :disabled="readonly"></el-input>
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col :span="24">
                                                <el-form-item label="执照图片">
                                                    <el-button type="primary" :disabled="readonly">上传图片</el-button>
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                    </el-form>
                                </el-card>
                                <el-card class="box-card" style="margin-top: 10px">
                                    <el-form :inline="true" ref="form2" :model="org.extend" label-width="80px">
                                        <el-row>
                                            <el-col :span="24">
                                                <el-form-item label="积分比例">
                                                    <el-input v-model="org.extend.pointScale" :disabled="readonly"></el-input>
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                    </el-form>
                                </el-card>
                            </el-tab-pane>
                            <el-tab-pane label="联系人" name="third">
                                <el-card class="box-card">
                                    <div style="margin-bottom: 10px" v-if="isPermission('org:addLink', user.permissions)">
                                        <el-button type="primary" @click="addLink">添加</el-button>
                                    </div>
                                    <el-table
                                            :data="org.linkList"
                                            border
                                            style="width: 100%">
                                        <el-table-column
                                                type="index"
                                                label="序号"
                                                width="80">
                                        </el-table-column>
                                        <el-table-column
                                                prop="name"
                                                label="姓名"
                                                width="180">
                                        </el-table-column>
                                        <el-table-column
                                                prop="type"
                                                label="类型">
                                        </el-table-column>
                                        <el-table-column
                                                prop="tel"
                                                label="电话">
                                        </el-table-column>
                                        <el-table-column
                                                prop="qq"
                                                label="qq">
                                        </el-table-column>
                                        <el-table-column
                                                prop="email"
                                                label="电子邮箱">
                                        </el-table-column>
                                        <el-table-column
                                                align="center"
                                                label="操作"
                                                inline-template>
                                            <div style="margin-left: -10px" v-if="isPermission('org:deleteLink', user.permissions)">
                                                <el-button size="small" type="primary" class="el-icon-delete" @click.native.prevent="deleteLink(row.id)"></el-button>
                                            </div>
                                        </el-table-column>
                                    </el-table>
                                </el-card>
                            </el-tab-pane>
                            <el-tab-pane label="账号信息" name="fourth">
                                <el-card class="box-card">
                                    <div style="margin-bottom: 10px" v-if="isPermission('user:add', user.permissions)">
                                        <el-button type="primary" @click="addAccount">添加</el-button>
                                    </div>
                                    <el-table
                                            :data="org.accountList"
                                            border
                                            style="width: 100%">
                                        <el-table-column
                                                type="index"
                                                label="序号"
                                                width="80">
                                        </el-table-column>
                                        <el-table-column
                                                prop="realName"
                                                label="姓名"
                                                width="180">
                                        </el-table-column>
                                        <el-table-column
                                                prop="enabled"
                                                label="状态"
                                                width="180"
                                                :formatter="formatterEnable">
                                        </el-table-column>
                                        <el-table-column
                                                prop="tel"
                                                label="电话">
                                        </el-table-column>
                                        <el-table-column
                                                prop="qq"
                                                label="qq">
                                        </el-table-column>
                                        <el-table-column
                                                prop="email"
                                                label="电子邮箱">
                                        </el-table-column>
                                        <el-table-column
                                                prop="regTime"
                                                label="创建时间"
                                                width="210">
                                        </el-table-column>
                                        <el-table-column
                                                align="center"
                                                label="操作"
                                                inline-template>
                                            <div style="margin-left: -10px">
                                                <el-dropdown>
                                                    <el-button size="small" type="primary">
                                                        操作<i class="el-icon-caret-bottom el-icon--right"></i>
                                                    </el-button>
                                                    <el-dropdown-menu slot="dropdown" align="center">
                                                        <el-dropdown-item v-if="isPermission('org:enableAccount', user.permissions)">
                                                            <el-button size="mini"  type="primary" class="el-icon-edit" v-if="row.enabled === 0" @click="enableAccount(row.id)">启用</el-button>
                                                            <el-button size="mini" type="primary" class="el-icon-edit" v-else @click="disableAccount(row.id)">禁用</el-button>
                                                        </el-dropdown-item>
                                                        <el-dropdown-item v-if="isPermission('org:deleteAccount', user.permissions)"><el-button size="mini" type="primary" class="el-icon-edit" @click="deleteAccount(row.id)">删除</el-button></el-dropdown-item>
                                                        <el-dropdown-item v-if="isPermission('user:reset', user.permissions)"><el-button size="mini" type="primary" @click.native.prevent="resetPassword(row.id)" class="el-icon-edit">重置密码</el-button></el-dropdown-item>
                                                    </el-dropdown-menu>
                                                </el-dropdown>
                                            </div>
                                        </el-table-column>
                                    </el-table>
                                </el-card>
                            </el-tab-pane>
                        </el-tabs>
                    </el-tab-pane>
                </el-tabs>
            </div>
            <!-- end content-right -->

            <el-dialog :title="linkTitle" v-model="linkDialog" size="tiny">
                <el-form :model="contactForm" :rules="linkRules" ref="contactForm" label-width="80px">
                    <el-form-item label="类型" prop="type">
                        <el-select v-model="contactForm.type" placeholder="请选择">
                            <el-option
                                    v-for="item in linkTypeList"
                                    :label="item.name"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="姓名" prop="name">
                        <el-input v-model="contactForm.name" style="width: 200px"></el-input>
                    </el-form-item>
                    <el-form-item label="电话" prop="tel">
                        <el-input v-model="contactForm.tel" style="width: 200px"></el-input>
                    </el-form-item>
                    <el-form-item label="qq">
                        <el-input v-model="contactForm.qq" style="width: 200px"></el-input>
                    </el-form-item>
                    <el-form-item label="电子邮箱">
                        <el-input v-model="contactForm.email" style="width: 200px"></el-input>
                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="linkDialog = false">取 消</el-button>
                    <el-button type="primary" @click="saveLink">确 定</el-button>
                </div>
            </el-dialog>
            <el-dialog :title="accountTitle" v-model="accountDialog" size="tiny">
                <el-form :model="accountForm" :rules="accountRules" ref="accountForm" label-width="80px">
                    <el-form-item label="状态" prop="enabled">
                        <el-select v-model="accountForm.enabled" placeholder="请选择状态">
                            <el-option label="禁用" :value="0"></el-option>
                            <el-option label="启用" :value="1"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="姓名" prop="realName">
                        <el-input v-model="accountForm.realName" style="width: 200px"></el-input>
                    </el-form-item>
                    <el-form-item label="电话" prop="tel">
                        <el-input v-model="accountForm.tel" style="width: 200px"></el-input>
                    </el-form-item>
                    <el-form-item label="qq">
                        <el-input v-model="accountForm.qq" style="width: 200px"></el-input>
                    </el-form-item>
                    <el-form-item label="电子邮箱">
                        <el-input v-model="accountForm.email" style="width: 200px"></el-input>
                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="linkDialog = false">取 消</el-button>
                    <el-button type="primary" @click="saveAccount">确 定</el-button>
                </div>
            </el-dialog>

            <a href="javascript:;" class="btn-leftMenuFold" id="j-btn-leftMenuFold"></a>
        </div>
    </div>
    <!-- end container -->

    <!--gonggao-->

    <!--tip-->
    <div class="footer">© 2017 , Inc. All rights reserved.</div>
    <!-- end footer -->
    <div class="fixedBar" style="right: -78px;">
        <ul>
            <template v-for="(item, index) in leftMenuList">
                <li v-if="index==0" :class="'shopManager' + index + ' cur'"><a href="javascript:;" :data-target="'#shop_' + index">{{item.groupName}}</a></li>
                <li v-else :class="'shopManager' + index"><a href="javascript:;" :data-target="'#shop_' + index">{{item.groupName}}</a></li>
            </template>
        </ul>
        <a href="javascript:;" class="fixedBar-btn" id="j-fixedBar-btn"></a>
    </div>
    <a href="#" id="j-gotop" class="gotop" title="回到顶部" style="left: 1920.59px;"></a>

</div>
<script src="/static/js/dist/lib-min.js"></script>
<script src="/static/js/dist/list.js"></script>
<script src="/static/js/dist/component-min.js"></script>

<!-- 引入api -->
<script src="/static/js/api.js"></script>
<script>
    new Vue({
        el: '#app',
        data: function(){
            return {
                readonly: true,
                qiniuUrl: list.qiniuUrl,
                userDataBtnEnable: false,
                user: ${(user)!'null'},
                userData: {
                    id: 0,
                    realName: '',
                    tel: '',
                    sex: '',
                    qq: '',
                    email: '',
                    avatar: ''
                },
                org: {
                    baseInfo: {

                    },
                    extend: {

                    },
                    linkList: [],
                    accountList: []
                },
                headerNavList: list.headerNavList,
                dialogFormVisible: false,
                accountTitle: '添加账号',
                accountDialog: false,
                addressLoading: false,
                linkDialog: false,
                linkTitle: '添加联系人',
                linkTypeList: [],
                contactForm: {},
                accountForm: {},
                extendRules: {
                    licenseCode: [
                        {required: true, message: "执照号码不能为空"}
                    ],
                    pointProportion: [
                        {required: true, message: "积分比例不能为空"},
                        {type: "number", message: '积分比例必须为数字'}
                    ]
                },
                linkRules: {
                    type: [
                        {required: true, message: "请选择类型"}
                    ],
                    name: [
                        {required: true, message: "姓名不能为空"}
                    ],
                    tel: [
                        {required: true, message: "电话不能为空"}
                    ]
                },
                accountRules: {
                    enabled: [
                        {required: true, message: "请选择状态"}
                    ],
                    realName: [
                        {required: true, message: "姓名不能为空"}
                    ],
                    tel: [
                        {required: true, message: "电话不能为空"}
                    ]
                },
                accountNavList: list.accountNavList,
                leftMenuList: list.menu,
                rules: {
//                    realName: [
//                        { required: true, message: '请输入原密码', trigger: 'blur' }
//                    ],
                    tel: [
                        { required: true, message: '请输入手机号码', trigger: 'blur' }
                    ]
                }
            }
        },
        mounted:function () {
            this.getUser()
            this.getOrg()
            this.getOrgLink()
        },
        methods: {
            formatterEnable(row){
                if (row.enabled === 1) {
                    return '启用'
                } else if (row.enabled === 0) {
                    return '禁用'
                }
            },
            resetPassword (id) {
                let that = this;
                this.$confirm('此操作将重置密码为初始密码, 是否继续?', '提示',{
                    confirmButtonText:'确定',
                    cancelButtonText:'取消',
                    type:'warning'
                }).then(function () {
                    that.resetPwd(id)
                }).catch(function () {
                    that.$message({
                        type: 'info',
                        message: '已取消重置'
                    });
                })
            },
            resetPwd (id) {
                let that = this;
                let loading = this.$loading({fullscreen: true, lock: true});
                this.http("/user/resettingPwd", {id: id}, function (res) {
                    if (res.status === 200) {
                        loading.close();
                        that.$alert('重置密码成功', '提示', {
                            confirmButtonText: '确定'
                        });
                    } else {
                        loading.close();
                        that.$alert(res.errMsg, '提示', {
                            confirmButtonText: '确定',
                        });
                    }
                }, function (res) {
                    loading.close();
                    that.$alert('服务器错误', '提示', {
                        confirmButtonText: '确定'
                    });
                })
            },
            enableAccount (id) {
                let that = this;
                let obj = {
                    id: id
                }
                this.http("/user/enable", obj, function (res) {
                    if (res.status === 200) {
                        that.$alert('启用成功', '提示', {
                            confirmButtonText: '确定',
                            callback: function () {
                                that.getOrg();
                            }
                        });
                    } else {
                        that.$alert('启用失败', '提示', {
                            confirmButtonText: '确定',
                        });
                    }
                }, function (res) {
                    that.$alert('启用失败', '提示', {
                        confirmButtonText: '确定',
                    });
                })
            },
            disableAccount (id) {
                let that = this;
                let obj = {
                    id: id
                }
                this.http("/user/disable", obj, function (res) {
                    if (res.status === 200) {
                        that.$alert('禁用成功', '提示', {
                            confirmButtonText: '确定',
                            callback: function () {
                                that.getOrg();
                            }
                        });
                    } else {
                        that.$alert('禁用失败', '提示', {
                            confirmButtonText: '确定',
                        });
                    }
                }, function (res) {
                    that.$alert('禁用失败', '提示', {
                        confirmButtonText: '确定',
                    });
                })
            },
            addLink () {
                this.contactForm = {
                    orgId: this.org.baseInfo.id,
                    type: '',
                    name: '',
                    tel: '',
                    qq: '',
                    email: ''
                }
                this.linkTitle = "添加联系人";
                this.linkDialog = true;
            },
            addAccount () {
                this.accountForm = {
                    orgId: this.org.baseInfo.id,
                    enabled: '',
                    realName: '',
                    tel: '',
                    qq: '',
                    email: ''
                }
                this.accountTitle = "添加账号";
                this.accountDialog = true;
            },
            getOrgLink () {
                let that = this;
                this.$get("/dictionary/list/SEC_ORG_LINK", {}, function (res) {
                    if (res.status === 100) {
                        that.linkTypeList = res.returnValue;
                    } else {
                        that.$alert('服务器错误','提示',{
                            confirmButtonText:'确定',
                        })
                    }
                }, function (res) {
                    that.$alert('服务器错误','提示',{
                        confirmButtonText:'确定',
                    })
                })
            },
            saveLink () {
                let that = this;
                let isVaild = true;
                this.$refs.contactForm.validate(function (valid) {
                    if (!valid) {
                        isVaild = false;
                    }
                })
                if (isVaild) {
                    let loading = this.$loading({fullscreen: true, lock: true, text: '保存中'});
                    this.http("/org/link/add", this.contactForm, function (res) {
                        if (res.status === 200) {
                            loading.close();
                            that.linkDialog = false;
                            that.$alert('保存联系人成功', '提示', {
                                confirmButtonText: '确定',
                                callback: function () {
                                    that.getOrg();
                                }
                            });
                        } else {
                            loading.close();
                            that.$alert('保存联系人失败', '提示', {
                                confirmButtonText: '确定',
                            });
                        }
                    }, function (res) {
                        loading.close();
                        that.$alert('保存联系人失败', '提示', {
                            confirmButtonText: '确定',
                        });
                    })
                } else {
                    that.$message.error('请完善信息');
                }
            },
            saveAccount () {
                let that = this;
                let isVaild = true;
                this.$refs.accountForm.validate(function (valid) {
                    if (!valid) {
                        isVaild = false;
                    }
                })
                if (isVaild) {
                    let loading = this.$loading({fullscreen: true, lock: true});
                    this.http("/org/account/add", this.accountForm,function (res) {
                        if (res.status === 200) {
                            loading.close();
                            that.accountDialog = false;
                            that.$alert('添加成功', '提示', {
                                confirmButtonText: '确定',
                                callback: function () {
                                    that.getOrg();
                                }
                            });
                        } else {
                            loading.close();
                            that.$alert('添加失败', '提示', {
                                confirmButtonText: '确定',
                            });
                        }
                    }, function (res) {
                        loading.close();
                        that.$alert('添加失败', '提示', {
                            confirmButtonText: '确定',
                        });
                    })
                } else {
                    that.$message.error('请完善信息');
                }
            },
            deleteAccount (id) {
                let that = this;
                this.$confirm('此操作将删除该账号, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(function () {
                    that.confirmDeleteAccount(id);
                }).catch(function () {
                    that.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            },
            confirmDeleteAccount (id) {
                let that = this;
                let loading = this.$loading({fullscreen: true, lock: true});
                this.http("/user/delete", {id: id}, function (res) {
                    if (res.status === 200) {
                        loading.close();
                        that.$alert('删除成功', '提示', {
                            confirmButtonText: '确定',
                            callback: function () {
                                that.getOrg()
                            }
                        });
                    } else {
                        loading.close();
                        that.$alert('删除失败', '提示', {
                            confirmButtonText: '确定',
                        });
                    }
                }, function (res) {
                    loading.close();
                    that.$alert('删除失败', '提示', {
                        confirmButtonText: '确定',
                    });
                })
            },
            deleteLink (id) {
                let that = this;
                this.$confirm('此操作将删除该联系人, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(function () {
                    that.confirmDeleteLink(id);
                }).catch(function () {
                    that.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            },
            confirmDeleteLink (id) {
                let that = this;
                let loading = this.$loading({fullscreen: true, lock: true, text: '保存中'});
                this.http("/org/link/delete", {id: id}, function (res) {
                    if (res.status === 200) {
                        loading.close();
                        that.$alert('删除成功', '提示', {
                            confirmButtonText: '确定',
                            callback: function () {
                                that.getOrg()
                            }
                        });
                    } else {
                        loading.close();
                        that.$alert('删除失败', '提示', {
                            confirmButtonText: '确定',
                        });
                    }
                }, function (res) {
                    loading.close();
                    that.$alert('删除失败', '提示', {
                        confirmButtonText: '确定',
                    });
                })
            },
            getUser() {
                let that = this
                this.$get('/user/get', null, function (res) {
                    if(res.status === 200){
                        let user = res.data.user;
                        that.userData.id = user.id
                        that.userData.realName = user.realName
                        that.userData.tel = user.tel
                        that.userData.sex = user.sex
                        that.userData.qq = user.qq
                        that.userData.email = user.email
                        that.userData.avatar = user.avatar
                    }else{
                        that.$alert(res.errMsg,'提示',{
                            confirmButtonText:'确定',
                        })
                    }
                },function (res) {
                    that.$alert('服务器错误','提示',{
                        confirmButtonText:'确定',
                    })
                })
            },
            getOrg() {
                let that = this
                this.$get('/user/getOrg', null, function (res) {
                    if(res.status === 200){
                        that.org = res.data
                    }else{
                        that.$alert(res.errMsg,'提示',{
                            confirmButtonText:'确定',
                        })
                    }
                },function (res) {
                    that.$alert('服务器错误','提示',{
                        confirmButtonText:'确定',
                    })
                })
            },
            saveUser () {
                var that = this
                let obj = {
                    id: this.userData.id,
                    realName: this.userData.realName,
                    tel: this.userData.tel,
                    sex: this.userData.sex,
                    qq: this.userData.qq,
                    email: this.userData.email,
                    avatar: this.userData.avatar
                };
                let url = '/user/update';
                this.http(url, obj, function (res) {
                    if (res.status === 200) {
                        that.$alert('修改成功', '提示', {
                            confirmButtonText: '确定'
                        });
                        that.getUser()
                    } else {
                        that.$alert(res.errMsg, '提示', {
                            confirmButtonText: '确定'
                        });
                    }
                }, function (res) {
                    that.$alert('服务器错误', '提示', {
                        confirmButtonText: '确定'
                    });
                })
            },
            cancelEdit () {
                this.getUser()
            },
            beforeUpload (file) {
                if (file.type === "image/png") {
                    this.imgType = ".png";
                    return true;
                } else if (file.type === "image/jpeg") {
                    this.imgType = ".jpg";
                    return true;
                } else {
                    this.$message.error('上传头像图片只能是 JPG 或 png 格式!');
                    return false;
                }
            },
            uploadSuccess (response, file) {
                if (response.status === 100) {
                    this.userData.avatar = response.returnValue[0].id + this.imgType;
                } else {
                    this.$alert('上传失败', '提示', {
                        confirmButtonText: '确定',
                    });
                }
            }
        }
    })
</script>

<!-- 20170105 --></body>
</html>